home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1078 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. From: alindbac@sw.seisy.abb.se (Anders Lindback)
  2. Message-ID: <4km1qj$bpu@sdaw04.seinf.abb.se>
  3. X-Original-Date: 12 Apr 1996 16:53:39 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 14 Apr 96 12:35:30 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Initialization of references.
  9. Organization: ABB Industrial Systems AB, Vdsteres, Sweden
  10. Reply-To: alindbac@sw.seisy.abb.se
  11. Summary: then is a reference initialized correctly
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMXDxNOEDnX0m9pzZAQE4UwF+LoFN22mv63OKmxyJIfdeGznMc8+8RD6J
  14.     sYW9exrHNovCQbGISKIfGFSZ/1tWXJHM
  15.     =Xjd1
  16.  
  17. The september 95 Working draft 8.3.1 says:
  18.  
  19. "A reference shall be initialized to refer to a valid object or function."
  20.  
  21. What is a valid object ? I can't find a good decription of that in
  22. the draft. Is it:
  23.  
  24. 1. An object that has storage.
  25. 2. An object which constructor has executed.
  26. 3. A typo ?
  27. 4. An out-of-date sentence in the draft.
  28. 5. None of the above ?
  29.  
  30. Example code from gnu.g++.help:
  31.  
  32. >#include <iostream.h>
  33. >
  34. >class Foo
  35. >{
  36. >public:
  37. >  Foo (int size_arg = 0) : size (my_size), my_size (size_arg),
  38. >    values (new double [size]) {}>
  39.   ~Foo () { delete values; }
  40. >  int const& size;
  41. >private:
  42. >  int my_size;
  43. >  double* values;
  44. >};
  45.  
  46. Is this code correct C++ code or not ?
  47.  
  48. Or must one change the order of the member variables in the
  49. class so that my_size is before size  and get to be intialized 
  50. first ?
  51.  
  52. And what will happend if they not are integers but actuall classes
  53. with constructors ?
  54.  
  55. Anders
  56. ---
  57. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  58. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  59. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  60. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  61. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  62.